package testes;

import logica.pessoa.Usuario;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TestaUsuario {

	private Usuario usuario;
	private Usuario usuario2;
	
	@Before public void inicializacao() throws Exception {
		
		usuario = new Usuario("Jose Arthur","(87) 38471149","arthur.programando@gmail.com", null,"2345678912","2345678",null,"br","art_login","123456","1234567");
		usuario2 = new Usuario("Jose Pedro","(87) 38471149","jose.ccc@gmail.com", null,"2385678912","7345678",null,"br","art_login_outro","234567","2345678");
	}

	
	@Test public void testLogin(){
		try{
			Assert.assertEquals("art_login", usuario.getLogin() );
			
			usuario.setLogin("peq                          ");
			
			Assert.fail();
		}
		catch (Exception e) {
			Assert.assertEquals("login deve ter mais de 5 caracteres", e.getMessage());
		}
		
		
		
		try{
			usuario.setLogin(null);
			
			Assert.fail();
		}
		catch (Exception e) {
			Assert.assertEquals("login deve ter mais de 5 caracteres", e.getMessage());
		}
		
		
		
		try{
			usuario2.setLogin("art_login");
			
			Assert.fail();
		}
		catch (Exception e) {
			Assert.assertEquals("login ja cadastrado", e.getMessage());
		}
	}
	
	
	
	@Test public void testSenha(){
		try{
			usuario.setSenha(null);
			
			Assert.fail();
		}
		catch (Exception e) {
			Assert.assertEquals("senha invalida", e.getMessage());
		}
	
	
		
		try{
			usuario.setSenha("                            peq");
			
			Assert.fail();
		}
		catch (Exception e) {
			Assert.assertEquals("senha invalida", e.getMessage());
		}
	}
	
	
	
	
	@Test public void testMatricula(){
		
		try{
			usuario.setMatricula("123456a");
			
			Assert.fail();
		}
		
		catch (Exception e) {
			Assert.assertEquals("matricula invalida", e.getMessage());
		}
		
		
		
		
		try{
			usuario.setMatricula("12345678");
			
			Assert.fail();
		}
		
		catch (Exception e) {
			Assert.assertEquals("matricula invalida", e.getMessage());
		}
		
		
		
		
		try{
			usuario.setMatricula("1 3 5 7");
			
			Assert.fail();
		}
		
		catch (Exception e) {
			Assert.assertEquals("matricula invalida", e.getMessage());
		}
		
		
		
		try{
			usuario.setMatricula("2345678");
			
			Assert.fail();
		}
		
		catch (Exception e) {
			Assert.assertEquals("matricula ja cadastrada", e.getMessage());
		}
	}
}
